const express = require('express');
const bodyParser = require('body-parser');

const app = express();
const PORT = 3000;

// Middleware to parse JSON bodies
app.use(bodyParser.json());

// Middleware to parse URL-encoded bodies
app.use(bodyParser.urlencoded({ extended: true }));

// Serve the HTML file
app.get('/', (req, res) => {
    res.sendFile(__dirname + '/register.html');
});

// Handle user registration
app.post('/register', (req, res) => {
    const { username, password } = req.body;

    // Here you would typically store the user data in a database
    // For simplicity, we'll just log it to the console
    console.log('User registered:', { username, password });

    // In a real application, you should hash the password before storing it
    // and send a proper response to the client

    res.send('User registered successfully!');
});

app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});